import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
  const plans = [
    { code: 'monthly', name: '一月', days: 30, price: 990, status: 1 },
    { code: 'yearly', name: '一年', days: 365, price: 7990, status: 1 },
    { code: 'lifetime', name: '永久', days: 36500, price: 19900, status: 1 },
  ];

  for (const p of plans) {
    await prisma.membershipPlan.upsert({
      where: { code: p.code },
      update: { name: p.name, days: p.days, price: p.price, status: p.status },
      create: p,
    });
  }

  console.log('Seed completed: membership plans upserted.');
}

main()
  .catch(e => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
